//
//  MCAfterGroupCapacityVc.swift
//  MCBodyBuildingPro
//
//  Created by Renlvshijie on 2023/5/31.
//

import UIKit
import QMUIKit
import JKSwiftExtension


//返回时间值
typealias timeInfoCapacityBlocks = (_ timeContent:MCCreatePlanaddDataModel?,_ index:Int?) -> Void


class MCAfterGroupCapacityVc: MCBaseVc {
    
    var timeInfoCapBlock:timeInfoCapacityBlocks?
    public var select:Int = 0
    public var actionInfoList:MCActionInfoActionList?
    public var actionType:Int = 0
    public var sortValue:Int = 0
    
    private var timeValue:Float = 0.0
    
    ///单个显示-各种数据
    lazy var lazyCapacityView:DYScrollRulerView = { [unowned self] in
        let unitStr     = "秒"
        let rulerHeight = DYScrollRulerView.rulerViewHeight
        var rulerView   = DYScrollRulerView.init(frame: CGRect.init(x: 5, y: 50, width: Int(ScreenWidth)-32, height: rulerHeight()), tminValue: 10, tmaxValue: 300, tstep: 10, tunit: unitStr, tNum:10, viewcontroller:self)
        rulerView.setDefaultValueAndAnimated(defaultValue: 150, animated: true)
        rulerView.bgColor       = UIColor.white
        rulerView.triangleColor = UIColor.white
        rulerView.delegate      = self
        rulerView.scrollByHand  = true
       return rulerView
    }()
    
    @IBOutlet weak var timesCapacityVIew: UIView!
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        self.view.backgroundColor = UIColor.qmui_color(withHexString: "#F7F7F9")
        self.navigationItem.title = "训练容量"
        self.timesCapacityVIew.addSubview(self.lazyCapacityView)
         
    }
     
    
    @IBAction func startBtn(_ sender: UIButton) {
        
        var timeModel = MCCreatePlanaddDataModel(JSON: [:])
        timeModel?.actionId = Int(actionInfoList?.id ?? "") ?? 0
        timeModel?.actionTime = Int(self.timeValue)
        timeModel?.actionType = actionType
        timeModel?.previewUrl = actionInfoList?.previewUrl ?? ""
        timeModel?.zhName = actionInfoList?.zhName ?? ""
        timeModel?.actionLabel = actionInfoList?.actionLabel ?? ""
        timeModel?.sort = self.sortValue
        if self.timeInfoCapBlock != nil {
            self.timeInfoCapBlock?(timeModel,select)
        }
        
       // self.navigationController?.jk.popToViewController(as: MCSelectActionVc.self, animated: true)
    }
    
    
    
}

extension MCAfterGroupCapacityVc:DYScrollRulerDelegate {
    func dyScrollRulerViewValueChange(rulerView: DYScrollRulerView, value: Float) {
        self.timeValue = value
    }
}

